FUNCTION

xy_to_pubkey

pure function xy_to_pubkey(x: big_integer, y: big_integer, [compressed: boolean]): byte_array

Construct a public key from EC point x and y coordinates. The given x and y coordinates must encode a point on the secp256k1 elliptic curve in order to constitute a public key.

Inverse of crypto.pubkey_to_xy().

The optional boolean flag compressed determines whether a compressed (33-byte), or uncompressed (65-byte) public key, is returned. Defaults to false (uncompressed) if not provided.

Parameters

  • x — the x-coordinate
  • y — the y-coordinate
  • compressed — whether the returned public key should be compressed, defaults to false

Returns

a 65-byte public key if uncompressed mode is used, or an equivalent 33-byte public key if compressed mode is used

Throws

  • exception — if the given x and y coordinates do not encode a point on the secp256k1 elliptic curve (and therefore do not constitute a valid public key)

Since

0.13.5

© 2026 Chromia